package mutilcore;

import java.util.Calendar;
import java.util.List;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.TimeUnit;

import util.Tools;

public class QuickSort {
    public static void main(String[] args) throws Exception {
        // 分别获取千、万、十万、百万级别的整数集
        List<Integer> tm = Tools.getThousandNums();
        List<Integer> ttm = Tools.getTenThousandNums();
        List<Integer> htm = Tools.getHundredThousandNums();
        List<Integer> mn = Tools.getMillionNums();

        long startTime = Calendar.getInstance().getTimeInMillis();

        ForkJoinPool forkJoinPool = new ForkJoinPool();
        forkJoinPool.submit(new QuickSortTask(tm));
        forkJoinPool.submit(new QuickSortTask(ttm));
        forkJoinPool.submit(new QuickSortTask(htm));
        forkJoinPool.submit(new QuickSortTask(mn));
        // 此处为秒，后面计算时，需要转为毫秒,
        forkJoinPool.awaitTermination(1, TimeUnit.SECONDS);
        long endTime = Calendar.getInstance().getTimeInMillis();
        System.out.println("开始时间: " + startTime);
        System.out.println("结束时间: " + endTime);
        System.out.println("使用时间(毫秒数):" + (endTime - startTime - 1000));
    }
}
